{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "MH_TEA.ipynb",
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "metadata": {
        "id": "r8MWeb81JTct"
      },
      "source": [
        "import numpy as np\n",
        "import pandas as pd \n",
        "from lightgbm import LGBMRegressor\n",
        "from sklearn.metrics import mean_squared_error"
      ],
      "execution_count": 1,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Sg7eBTtpKKrU"
      },
      "source": [
        "train=pd.read_csv('train.csv')\n",
        "test=pd.read_csv('test.csv')\n",
        "sub=pd.read_csv('submission.csv')"
      ],
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ta3VzlN9K3Mv"
      },
      "source": [
        "cols=train.columns\n",
        "dat=pd.concat([train,test])\n",
        "for col in cols[1:]:\n",
        "  dat[col]=dat[col].replace('N.S.',np.nan)\n",
        "  dat[col]=dat[col].replace('NS',np.nan)\n",
        "  dat[col]=dat[col].replace('No Sale',np.nan)\n",
        "  dat[col]=dat[col].replace('N.S',np.nan)\n",
        "  dat[col]=dat[col].replace('N. S.',np.nan)\n",
        "  dat[col]=dat[col].replace('No sale',np.nan)\n",
        "  dat[col]=dat[col].replace('N.S.\\xa0',np.nan)\n",
        "  dat[col]=dat[col].replace('NS85.07',np.nan)\n",
        "  dat[col]=dat[col].astype(np.float64)\n",
        "  dat[col]=dat[col].interpolate('linear')"
      ],
      "execution_count": 3,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "c3dJGQzbLj7n"
      },
      "source": [
        "dat.fillna(value=87.48,inplace=True)"
      ],
      "execution_count": 4,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "JgQw9dO7MzXw"
      },
      "source": [
        "train=dat[:len(train)]\n",
        "test=dat[len(train):]"
      ],
      "execution_count": 5,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "MGVnweLHOoTd"
      },
      "source": [
        "X=train.drop(['Average','WeekEnding_Date'],axis=1)\n",
        "y=train['Average']"
      ],
      "execution_count": 6,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "bHXSgqYpYA4s"
      },
      "source": [
        "X_test=test.drop(['Average','WeekEnding_Date'],axis=1)"
      ],
      "execution_count": 7,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "-Oe7I_vAYEXH"
      },
      "source": [
        "X_train,X_val=X.iloc[:450],X.iloc[450:]\n",
        "y_train,y_val=y[:450],y[450:]"
      ],
      "execution_count": 8,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "HYOa8MPHZYcR"
      },
      "source": [
        "preds=X_test.mean(axis=1)\n",
        "# preds=model.predict(X_test)"
      ],
      "execution_count": 9,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Ed84xEBsfKTM"
      },
      "source": [
        "sub['Average']=preds\n",
        "sub.to_csv('pred2_tea.csv',index=False)"
      ],
      "execution_count": 10,
      "outputs": []
    }
  ]
}